import React from "react";
import { PageCont } from "@/components/page-cont";
import { PageTable } from "@/components/page-table";
import { CapabilityButton } from "@/components/capability";
import * as capabilities from "./capabilities";
import * as constant from "./constant";
import * as apis from "@shared/apis";

/** 用户管理 */
export default function SystemAccount() {

    const { controller, refresh } = PageTable.useController<apis.users.IUser>();
    const capabilityData = React.useMemo(() => ({ refresh }), [refresh]);

    return (
        <PageCont>
            <PageTable
                rowKey='id'
                controller={controller}
                api={apis.users.list.post}
                filterProps={constant.filterProps}
                columns={constant.columns}
                extendLeft={[
                    <CapabilityButton capability={capabilities.createUser} data={capabilityData} buttonProps={{ type: 'primary' }} />,
                ]}
                operation={{
                    width: 100,
                    expandOutList: [
                        capabilities.editUser,
                        capabilities.deleteUser,
                    ],
                }}
            />
        </PageCont>
    )
}

